package api_day06;

import java.io.Serializable; //在day10的学习中用到

public class Student implements Comparable<Student>,Serializable{
    String name;
    int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public int compareTo(Student s) {
        if (age != s.age){
            return age - s.age;
        }else {
            return name.compareTo(s.name);
        }
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
